package com.xh.bussiness.tiku.bean.request;

import com.baomidou.mybatisplus.annotation.TableField;
import com.xh.bussiness.tiku.model.QuestionSource;
import com.xh.core.bean.BaseRequestBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 试题表 查询bean
 * </p>
 *
 * @author daiwei
 * @since 2019-01-14
 */
@ApiModel(value = "QuestionQueryRequest", description = "试题查询参数对象")
@Data
public class QuestionQueryRequest extends BaseRequestBean {

	/**
	 * id
	 */
	@ApiModelProperty(value = "id", notes = "id", dataType = "String", required = false)
	private String id;
	/**
	 * 题干
	 */
	@ApiModelProperty(value = "题干", notes = "试题题干", dataType = "String", required = false)
	private String title;

	/**
	 * 学科
	 */
	@ApiModelProperty(value = "科目id", notes = "科目id", dataType = "String")
	private String subject;
	
	/**
	 * 科目
	 */
	@ApiModelProperty(value = "科目id", notes = "科目id", dataType = "String[]")
	private List<String> subjectIds;
	/**
	 * 第一级知识点
	 */
	private String bookVersionId;
	/**
	 * 第二级知识点
	 */
	private String bookChapterId;
	
	/**
	 * 知识点
	 */
	@ApiModelProperty(value = "知识点集合", notes = "知识点集合", dataType = "String[]")
	private List<String> knowledgePoints;

	@ApiModelProperty(value = "章节集合",notes = "章节集合",dataType = "String[]")
	private List<String> chapters;

	@ApiModelProperty(value = "章节下知识点集合",notes = "章节下知识点集合",dataType = "String[]")
	private List<String> chapterKnowles;

	/**
	 * 题型
	 */
	@ApiModelProperty(value = "题型", notes = "题型", dataType = "Integer")
	private Integer type;

	/**
	 * 题型
	 */
	@ApiModelProperty(value = "题型", notes = "题型", dataType = "Integer[]")
	private List<Integer> types;
	/**
	 * 难度
	 */
	@ApiModelProperty(value = "难度", notes = "难度", dataType = "Integer")
	private Integer difficult;
	/**
	 * 难度
	 */
	@ApiModelProperty(value = "难度", notes = "难度", dataType = "Integer[]", required = false)
	private List<Integer> difficults;
	
	/**
	 * 类型
	 */
	@ApiModelProperty(value = "类别", notes = "类别", dataType = "String[]", required = false)
	private String category;
	/**
	 * 类型
	 */
	@ApiModelProperty(value = "类别", notes = "类别", dataType = "String[]", required = false)
	private List<String> categorys;
	
	/**
	 * 年份
	 */
	@ApiModelProperty(value = "年份", notes = "年份", dataType = "String[]", required = false)
	private String year;
	/**
	 * 年份
	 */
	@ApiModelProperty(value = "年份", notes = "年份", dataType = "String[]", required = false)
	private List<String> years;
	/**
	 * 数据来源：1 菁优网 2 精品库 3 个人库
	 */
	@ApiModelProperty(value = "数据来源", notes = "数据来源：1 菁优网 2 精品库 3 个人库", dataType = "Integer", required = true)
	private Integer dataType;
	/**
	 * 查询方式：1 按章节查询  2 按考点查询
	 */
	@ApiModelProperty(value = "查询方式", notes = "查询方式：1 按章节查询  2 按考点查询", dataType = "Integer", required = true)
	private Integer searchType;

	/**
	 * 年级id
	 */
	@ApiModelProperty(value = "年级", notes = "年级", dataType = "String", required = false)
	private String gradeId;


	@ApiModelProperty(value = "多个年级", notes = "多个年级", dataType = "String[]", required = false)
	private List<String> gradeIds;

	/**
	 * 是否绑定知识点 0未绑定知识点 1已绑定知识点
	 */
	private Integer knowledgePointBind;

	/**
	 * 创建人id
	 */
	@ApiModelProperty(value = "创建人id", notes = "创建人id", dataType = "String")
	private String creatorId;
	
	/**
	 * 地区
	 */
	@ApiModelProperty(value = "地区", notes = "地区", dataType = "String")
	private String region;
	/**
	 * 地区
	 */
	@ApiModelProperty(value = "地区", notes = "地区", dataType = "String")
	private List<String> regions;
	/**
	 * 排序（0：创建时间；1：试题难度；2：引用次数）
	 */
	@ApiModelProperty(value = "排序", notes = "排序（1：文件名；2：上传时间；3：引用次数）", dataType = "String")
	private Integer order;
	/**
	 * 升降（0：升序；1：降序）
	 */
	@ApiModelProperty(value = "排序方式", notes = "升降（0：升序；1：降序）", dataType = "String")
	private Integer orderType = 0;
	
	
	@ApiModelProperty(value = "来源", notes = "来源", dataType = "String")
	private String source;
	
	@ApiModelProperty(value = "来源", notes = "来源", dataType = "String")
	private List<String> sources;
	
	/**
	 * 随机取题数
	 */
	@ApiModelProperty(value = "随机取题数", notes = "随机取题数", dataType = "Integer", required = false)
	private Integer randomCount;

	@ApiModelProperty("随机取题开始位置")
	private Integer randomStart;

	@ApiModelProperty("随机取题拉取题数")
	private Integer randomFetchSize;

	@ApiModelProperty("知识节点路径ID")
	private String path;
	
	private List<String> questions;

	private Integer  status;

	@ApiModelProperty("试题来源")
	private QuestionSource questionSource;

	//是否包含试题来源条件
	private Integer hasQuesSourceCondition;

	//前端不好传参，放在外面了
	private List<String> dictSourceIds;
	public List<String> publicSchoolIds;

	/**
	 * 由于分页查询试题参数格式有问题 单独声明到该dto
	 */
	private long current;
	private long size;

	//前端参数不好传，放在request里面想questionSource复制
	public void setQuestionSourceVal() {
		if (!CollectionUtils.isEmpty(years)) {
			this.questionSource = this.questionSource == null ? new QuestionSource() : questionSource;
			questionSource.setYears(years);
		}
		if (!CollectionUtils.isEmpty(dictSourceIds)) {
			this.questionSource = this.questionSource == null ? new QuestionSource() : questionSource;
			questionSource.setDictSourceIds(dictSourceIds);
		}
		if (!CollectionUtils.isEmpty(publicSchoolIds)) {
			this.questionSource = this.questionSource == null ? new QuestionSource() : questionSource;
			questionSource.setPublicSchoolIds(publicSchoolIds);
		}
	}
}
